﻿<%@ Page Title="Registration" Language="C#" MasterPageFile="~/Header-Footer.master" AutoEventWireup="true" CodeFile="Reg-Registration-User.aspx.cs" Inherits="Registration_User" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

<script type="text/javascript">

    function validate() {
        var uname = document.getElementById('<%=txtUsername.ClientID %>').value;
        var email = document.getElementById('<%=txtEmail.ClientID %>').value;
        var result1 = CheckUserName(uname);
        var result = CheckEmail(email);
        if (result == 'true' && result1 == 'true')
            return true;
        else return false;
    }
    function CheckUserName(val) {
        var username = document.getElementById('<%=hdnValidUserName.ClientID %>');
        username.value = 'false';
        if (val != '') {
            var text = { "UserName": val };
            $.ajax({
                type: "POST",
                url: "WebServices/Validations.asmx/CheckUserName",
                data: JSON.stringify(text),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (msg) {
                    if (msg.d != '') {
                        if (msg.d == 'True') {
                            username.value = 'false';
                            $('#divMessage').attr('style', 'color:red');
                            $('#divMessage').html('This User Name already exists');
                            return 'false';
                        }
                        else {
                            username.value = 'true';
                            $('#divMessage').attr('style', 'color:Green');
                            $('#divMessage').html('ok');
                            return 'true';
                        }
                    }
                }
            });
        }
        else {
            $('#divMessage').attr('style', 'color:red');
            $('#divMessage').html('User name can not be blank.');
            username.value = 'false';
            return 'false';
        }
        return 'true';
    }



    function CheckEmail(val) {
        var hdnemail = document.getElementById('<%=hdnValidEmail.ClientID %>');
        hdnemail.value = 'false';
        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
        if (val != '') {
            if (reg.test(val) == false) {
                $('#divEmailMessage').attr('style', 'color:red');
                $('#divEmailMessage').html('Please Enter valid Email');
            }
            else {
                var text = { "Email": val };
                $.ajax({
                    type: "POST",
                    url: "WebServices/Validations.asmx/CheckEmail",
                    data: JSON.stringify(text),
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (msg) {
                        if (msg.d == 'True') {
                            hdnemail.value = 'false';
                            $('#divEmailMessage').attr('style', 'color:red');
                            $('#divEmailMessage').html('This Email already exists');
                            return 'false';
                        }
                        else {
                            hdnemail.value = 'true';
                            $('#divEmailMessage').attr('style', 'color:Green');
                            $('#divEmailMessage').html('ok');
                            return 'true';
                        }
                    }
                });
            }
        }
        else {
            $('#divEmailMessage').attr('style', 'color:red');
            $('#divEmailMessage').html('Email can not be blank.');
            hdnemail.value = 'false';
            return 'false';
        }
        return 'true';
    }
     
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<section> 
<br />
<br />
<br />
<div class="col_right article">
<h1>Registration</h1>


<asp:HiddenField ID="hdnValidEmail" runat="server" />
<asp:HiddenField ID="hdnValidUserName" runat="server" /> 



<div class="section">
    <h1 class="register">Register with Your Social Account</h1>    
    <div class="cb"></div>
    
    <div class="bigWarpper register">
        <h1>Create an account</h1>
       
        <section class="section">
            <h1>Account Details</h1>        
             <asp:UpdatePanel ID="sdf" runat="server" UpdateMode="Conditional"><ContentTemplate>
            <div class="user-form">
            	<div><label class="required">First Name</label><input type="text"  name="" id="txtFirstName" runat="server" maxlength="200"/></div>
                <div><label class="required">Last Name</label><input type="text"  name="" id="txtLastName" runat="server" maxlength="200"/></div>
                <div><label class="required">Your Email</label><input type="text"  maxlength="250"  onblur="CheckEmail(this.value);" name="" id="txtEmail" runat="server"/></div>
                <div><label class="required">User Name</label><input type="text"   maxlength="250"  onblur="CheckUserName(this.value);"  name=""  id="txtUsername" runat="server"/></div>
                <div><label class="required">Password</label><asp:TextBox TextMode="Password"    MaxLength="50" ID="txtPassword" runat="server"/></div>             
                <div><label class="required">Confirm Password</label><asp:TextBox TextMode="Password"  ID="txtCPass" runat="server"/></div>
                <div><label class="required">University</label>              <asp:DropDownList ID="ddlUniversity" CssClass="droupdownlist dropdownarrowstyle" runat="server" AppendDataBoundItems="true" OnSelectedIndexChanged="ddlUniversity_SelectedIndexChanged" AutoPostBack="true">
                  <asp:ListItem Text="Select" Value="0"></asp:ListItem>
                  </asp:DropDownList>
                <div class="listbox_icon_profile"></div> 
                  </div>             
                <div id="divCollege" runat="server"><label class="required">College</label>    <asp:DropDownList ID="ddlCollege" 
                        CssClass="droupdownlist dropdownarrowstyle"
                        runat="server" AppendDataBoundItems="true" 
                        onselectedindexchanged="ddlCollege_SelectedIndexChanged" AutoPostBack="true">
                  <asp:ListItem Text="Select" Value="0"></asp:ListItem>
                  </asp:DropDownList></div>
                <div><label class="required">Mobile</label><asp:TextBox ID="txtMobile" runat="server"  MaxLength="10"/></div>
                <div id="divOtherCollege"  class="hide mr0px" runat="server"> <label class="required">College</label><asp:TextBox ID="txtCollege" runat="server" MaxLength="250"/></div>
                
                <div style=""><asp:CheckBox ID="chkDisclose" runat="server" Text="Do you want to disclose your number on our site?" ></asp:CheckBox><label></label></div>
                <div class="cb"></div>
                
             <div class="btns">
				<a href="#" class="cancelbtn">Cancel</a>
				<%--<input type="submit" value="Submit" class="submitbtn" id="btnSave" runat="server" onclick="btnSave_Click">--%>
<asp:Button ID="Button1" Text="Submit" runat="server"  onclick="btnSave_Click"/>

<label id="divMessage" class="textfr"></label>
<label id="divEmailMessage" class="textfr"></label>
<asp:Label ID="lblError" runat="server"  EnableViewState="false"></asp:Label>

			</div>               
            </div>    
            </ContentTemplate></asp:UpdatePanel>    
        </section>
    </div>
</div>
<script>
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_endRequest(EndRequestHandler);

    function EndRequestHandler(sender, args) {
        $(function () {
            $(".fbox").fancybox({
                'width': 585,
                'height': 212,
                'autoScale': false,
                'transitionIn': 'elastic',
                'transitionOut': 'elastic',
                'type': 'iframe',
                'hideOnOverlayClick': true,
                'centerOnScroll': true
            });
        });

    } 

</script>


</div>

<div class="cb"></div>
</section>
<!--End section-->
</asp:Content>

